package com.weiyan.blog.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * @author misterWei
 * @create 2020年01月20号:18点01分
 * @mailbox mynameisweiyan@gmail.com
 */
@Configuration
//基于方法的认证权限
@EnableGlobalMethodSecurity(prePostEnabled = true,securedEnabled = true)
public class WebSecruityConfig extends WebSecurityConfigurerAdapter {



    @Override
    protected void configure(HttpSecurity http) throws Exception {
       http.csrf().disable()
                .authorizeRequests()
                       .anyRequest()
                         .authenticated()  //所有请求必须通过认证
                           .and()
                            .formLogin();
    }

}
